#与门的实现
def AND(x1, x2):
    w1, w2, theta = 0.5, 0.5, 0.7
    tmp = x1*w1 + x2*w2
    if tmp <= theta:
        return 0
    elif tmp > theta:
        return 1
#或门的实现
def OR(x1,x2):    
    w1,w2,theta=0.5,0.5,0.2
    tmp=x1*w1+x2*w2
    if tmp<=theta:
        return 0
    elif tmp>theta:
        return 1
#与非门
def NAND(x1,x2):
    w1, w2, theta = -0.5, -0.5, -0.7
    tmp = x1*w1 + x2*w2
    if tmp <= theta:
        return 0
    elif tmp > theta:
        return 1


def main():
    print(AND(0,0))    
    print(AND(0,1))    
    print(AND(1,0))    
    print(AND(1,1))    
    
    print(OR(0,0))    
    print(OR(0,1))    
    print(OR(1,0))    
    print(OR(1,1))   

    print(NAND(0,0)) 
    print(NAND(0,1)) 
    print(NAND(1,0)) 
    print(NAND(1,1)) 
if __name__=="__main__":
    main()